#ifndef AUDIOMANAGER_H
#define AUDIOMANAGER_H

#include <QThread>
#include <QAudioOutput>
#include <QFile>
#include <QtGlobal>
#include <qtopiaapplication.h>
#include <QString>

class AudioManager : public QThread
{
	Q_OBJECT
	
	public:
		static const int FREQUENCY = 11025;
        static const int CHANNELS = 1;
        static const int BIT_DEPTH = 16;
		static const int BIT_RATE = FREQUENCY * BIT_DEPTH * CHANNELS;
        static const int BYTE_RATE = (int) ((FREQUENCY/10.0) * CHANNELS * BIT_DEPTH/8) + 
				((int) ((FREQUENCY/10.0) * CHANNELS * BIT_DEPTH/8)) % 2;
		AudioManager();
		~AudioManager();
		void setAudio(QString filename);
		int getDuration();
		int getOffset();
		void setOffset(int offset);
		void run();
		void play(int offset);
		void stop();

	private:
		QAudioOutput *audioOutput;
		QFile *audioFile;
		bool needPlay;

		

	signals:
		void audioPlayingSignal(int time);
		void audioFinishingSignal();
	private slots:
	
	
};

#endif
